using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Dao;
using Common;
using Model;
using Newtonsoft.Json;
using Microsoft.AspNetCore.Http;
namespace SettingServer.Controllers
{
   
    public class LoginController : ControllerBase
    {
        [HttpPost]
        public string Login(string usercode, string userpow)
        {
            try
            {
                Permit_User admin = new Permit_UserDM().Get_UserBM(usercode,userpow);
                if(admin != null)
                {
                  admin.pow ="";
                  OperationRedis.StringSet("login" + HttpContext.Session.Id, JsonConvert.SerializeObject(admin), DateTime.Now.AddMinutes(30) - DateTime.Now);
                  return HttpContext.Session.Id;
                }else
                {
                    return "error:没有这个用户！";
                }
                
            }
            catch (System.Exception ex)
            {
                return "error"+ex.Message;
            }
            
        }
    }
}
